//
//  RegisterView.m
//  BakeCenter
//
//  Created by Barnett Wu on 15/9/23.
//  Copyright (c) 2015年 Baked. All rights reserved.
//

#import "RegisterView.h"

@implementation RegisterView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.titleImageView = [[UIImageView alloc] init];
        self.titleImageView.backgroundColor = [UIColor eggplantColor];
        self.titleImageView.image = [UIImage imageNamed:@"注册界面.jpg"];
        
        self.userNameLabel    = [[UILabel alloc] init];
        self.userNameLabel.text = @"用户名";
        self.userNameLabel.textColor = [UIColor siennaColor];
        self.userNameLabel.backgroundColor = [UIColor clearColor];
        self.userNameLabel.textColor = [UIColor siennaColor];

        self.userTextField    = [[UITextField alloc] init];
        self.userTextField.backgroundColor = [UIColor sandColor];
        
        self.codeLabel        = [[UILabel alloc]init];
        self.codeLabel.backgroundColor = [UIColor sandColor];
        self.codeLabel.text = @"密码";
        self.codeLabel.backgroundColor = [UIColor clearColor];
        self.codeLabel.textColor = [UIColor siennaColor];
        
        self.codeTextField    = [[UITextField alloc]init];
        self.codeTextField.backgroundColor = [UIColor sandColor];
        self.affirmLabel      = [[UILabel alloc] init];
        self.affirmLabel.text = @"密码确认";
        self.affirmLabel.backgroundColor = [UIColor clearColor];
        self.affirmLabel.textColor = [UIColor siennaColor];


        self.affirmTextField  = [[UITextField alloc]init];
        self.affirmTextField.backgroundColor = [UIColor sandColor];
        self.phoneLabel       = [[UILabel alloc] init];
        self.phoneLabel.text = @"手机号码";
        self.phoneLabel.textColor = [UIColor siennaColor];

        self.phoneLabel.backgroundColor = [UIColor clearColor];
        self.phoneTextField   = [[UITextField alloc] init];
        self.phoneTextField.backgroundColor = [UIColor sandColor];
        self.mailboxLabel     = [[UILabel alloc]init];
        self.mailboxLabel.text = @"邮箱";
        self.mailboxLabel.textColor = [UIColor siennaColor];
        self.mailboxLabel.backgroundColor = [UIColor clearColor];
        self.mailboxTextField = [[UITextField alloc] init];
        self.mailboxTextField.backgroundColor = [UIColor sandColor];

        self.registerButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.registerButton.backgroundColor = [UIColor sandColor];
        [self.registerButton setTitle:@"注册" forState:(UIControlStateNormal)];
        [self.registerButton addTarget:self action:@selector(registerInto:) forControlEvents:(UIControlEventTouchUpInside)];
        
        
        [self addSubview:self.titleImageView];
        [self addSubview:self.userNameLabel];
        [self addSubview:self.userTextField];
        [self addSubview:self.codeLabel];
        [self addSubview:self.codeTextField];
        [self addSubview:self.affirmLabel];
        [self addSubview:self.affirmTextField];
        [self addSubview:self.phoneLabel];
        [self addSubview:self.phoneTextField];
        [self addSubview:self.mailboxLabel];
        [self addSubview:self.mailboxTextField];
        [self addSubview:self.registerButton];
        
        
        [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.top).offset(72);
            make.height.mas_equalTo(@150);
            make.left.mas_equalTo(self.left).offset(10);
            make.right.mas_equalTo(self.right).offset(-10);
            
        }];
        
        [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.titleImageView.mas_bottom).offset(10);
            make.height.mas_equalTo(@40);
            make.left.mas_equalTo(self.titleImageView.mas_left).offset(30);
            make.width.mas_equalTo(@80);
        }];
        
        [self.codeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.userNameLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(@40);
            make.left.mas_equalTo(self.titleImageView.mas_left).offset(30);
            make.width.mas_equalTo(self.userNameLabel);
        
        }];
        
        [self.affirmLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.codeLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(self.userNameLabel);
            make.left.mas_equalTo(self.userNameLabel);
            make.width.mas_equalTo(self.userNameLabel);
        }];
        
        [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.affirmLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(self.userNameLabel);
            make.left.mas_equalTo(self.userNameLabel);
            make.width.mas_equalTo(self.userNameLabel);
        }];
        
        [self.mailboxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.phoneLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(self.userNameLabel);
            make.left.mas_equalTo(self.userNameLabel);
            make.width.mas_equalTo(self.userNameLabel);
        }];
        
        [self.userTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.userNameLabel.mas_right).offset(15);
            make.height.mas_equalTo(self.userNameLabel);
            make.right.mas_equalTo(self.mas_right).offset(-30);
            make.top.mas_equalTo(self.userNameLabel);
        }
        ];
        
        [self.codeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.codeLabel.mas_right).offset(15);
            make.height.mas_equalTo(self.userNameLabel);
            make.width.mas_equalTo(self.userTextField);
            make.top.mas_equalTo(self.codeLabel);
        }
        ];
        
        [self.affirmTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.affirmLabel.mas_right).offset(15);
            make.height.mas_equalTo(self.userNameLabel);
            make.width.mas_equalTo(self.userTextField);
            make.top.mas_equalTo(self.affirmLabel);
        }
         ];
        
        [self.phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.phoneLabel.mas_right).offset(15);
            make.height.mas_equalTo(self.userNameLabel);
            make.width.mas_equalTo(self.userTextField);
            make.top.mas_equalTo(self.phoneLabel);
        }
         ];
        
        [self.mailboxTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.mailboxLabel.mas_right).offset(15);
            make.height.mas_equalTo(self.userNameLabel);
            make.width.mas_equalTo(self.userTextField);
            make.top.mas_equalTo(self.mailboxLabel);
        }
         ];
        
        [self.registerButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self.mas_centerX);
            make.height.mas_equalTo(@40);
            make.width.mas_equalTo(@120);
            make.top.mas_equalTo(self.mailboxTextField.mas_bottom).offset(20);
        }
        ];
    }

    return self;
}

- (void)registerInto:(UIButton *)button
{

}



@end
